﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using TyMES.Model.BaseInformation;


namespace TyMES.ViewModel.BaseInformation.ProduceDataTypeVMs
{
    public partial class ProduceDataTypeListVM : BasePagedListVM<ProduceDataType_View, ProduceDataTypeSearcher>
    {

        protected override IEnumerable<IGridColumn<ProduceDataType_View>> InitGridHeader()
        {
            return new List<GridColumn<ProduceDataType_View>>{
                this.MakeGridHeader(x => x.lineCode),
                this.MakeGridHeader(x => x.stationCode),
                this.MakeGridHeader(x => x.dataType),
                this.MakeGridHeader(x => x.nameTable),
                this.MakeGridHeader(x => x.orderCode),
                this.MakeGridHeader(x => x.scheduleCode),
                this.MakeGridHeader(x => x.machineCode),
                this.MakeGridHeaderAction(width: 200)
            };
        }

        public override IOrderedQueryable<ProduceDataType_View> GetSearchQuery()
        {
            var query = DC.Set<ProduceDataType>()
                .CheckContain(Searcher.lineCode, x=>x.lineCode)
                .CheckContain(Searcher.stationCode, x=>x.stationCode)
                .CheckContain(Searcher.dataType, x=>x.dataType)
                .CheckContain(Searcher.orderCode, x=>x.orderCode)
                .CheckContain(Searcher.scheduleCode, x=>x.scheduleCode)
                .CheckContain(Searcher.machineCode, x=>x.machineCode)
                .Select(x => new ProduceDataType_View
                {
				    ID = x.ID,
                    lineCode = x.lineCode,
                    stationCode = x.stationCode,
                    dataType = x.dataType,
                    nameTable = x.nameTable,
                    orderCode = x.orderCode,
                    scheduleCode = x.scheduleCode,
                    machineCode = x.machineCode,
                })
                .OrderBy(x => x.ID);
            return query;
        }

    }

    public class ProduceDataType_View : ProduceDataType{

    }
}
